#include<math.h>

class Solution {
public:
    bool IsBalanced_Solution(TreeNode* pRoot) {
            return (getBannance(pRoot)!=-1);
    }

    
    int getBannance(TreeNode *pBoot)
    {
        if(pBoot==nullptr)
        {
            return 0;
        }
        int left=getBannance(pBoot->left);
        if(left==-1)
            return -1;
        int right=getBannance(pBoot->right);
        if(right==-1)
            return -1;
        
        return abs(left-right)>1?-1:1+max(left,right);   ///注意这里要多个 1+  自己写的时候漏掉了
        
        
    }
    
    
    
    
    
    
};